use "F:\Dropbox\School\Research Projects\Datasets\PSAS\Country studies\spain\PSAS_spain_v03062020.dta", clear

log using "F:\Dropbox\School\Research Projects\Datasets\PSAS\Country studies\Spain\spain rep log for cb.log", replace

sem (ANGER-> angry outrage fury irritated) (FEAR->tense scared nervous afraid) (POSAFF-> encouraged enthusiastic proud) /*
*/ (NEGAFF->ashamed uneasy), var(ANGER@1 FEAR@1 POSAFF@1 NEGAFF@1) /*
*/method(mlmv) standardized  cov(e.encouraged*e.proud) cov(e.angry*e.fury)
estat gof, stat(all)
estat eqgof

sem (ANGER-> angry outrage fury irritated) (FEAR->tense scared nervous afraid) (NEGAFF->ashamed uneasy), var(ANGER@1 FEAR@1 NEGAFF@1) /*
*/method(mlmv) standardized  cov(e.angry*e.fury)  cov(e.tense*e.nervous) cov(e.nervous*e.uneasy)
estat gof, stat(all)
estat eqgof

sem (CULTDISC-> cd1 cd2 cd4 cd8 cd9) (IDMARG-> cd6 cd16 cd20), /*
*/var(CULTDISC@1 IDMARG@1) method(mlmv) standardized cov(e.cd4*e.cd6)
estat gof, stat(all)
estat eqgof

sem (ANT-> ant1@1 ant2 ant3) (PPL-> ppl1@1 ppl2 ppl3) (MAN->man1@1 man3) (METHOD-> ant2@1 ppl2@a),/*
*/method(mlmv) standardized
estat gof, stat(all)
estat eqgof

sem (ANTALT-> ant1@1 ant2 ant3) (PPLALT-> ppl1@1 ppl2 ppl3),/*
*/method(mlmv) standardized cov(e.ant2*e.ppl2)
estat gof, stat(all)
estat eqgof

sem (CONSP-> consp1 consp2 consp3 consp4 consp5) /*
*/, var(CONSP@1) method(mlmv) standardized
estat gof, stat(all)
estat eqgof

sem (PREJ_VOX-> prej_vox*) (PREJ_POD->prej_podemos*), var(PREJ_VOX@1 PREJ_POD@1)/*
*/method(mlmv) standardized
estat gof, stat(all)
estat eqgof

sem (PREJ_ALT-> prej_imm prej_roma prej_mor prej_af prej_lat), var(PREJ_ALT@1) method(mlmv) standardized
estat gof, stat(all)
estat eqgof

*generates punitivism measure
sem (PP-> pp1 pp2 pp3 pp4 pp5 pp6 pp7), var(PP@1) cov(e.pp4*e.pp5) cov(e.pp2*e.pp4) cov(e.pp3*e.pp6) cov(e.pp5*e.pp7) method(mlmv) standardized
estat gof, stat(all)
estat eqgof

sem (EFF->eff1 eff4 eff3 eff5) (PERF-> perf1 perf2 perf3 perf4 perf5) (RS->rs_1 rs_2 rs_3),/*
*/ var(EFF@1 PERF@1 RS@1) method(mlmv) standardized cov(e.eff4*e.eff3)
estat gof, stat(all)
estat eqgof

sem (IMM->imm4 imm5 imm6), var(IMM@1) method(mlmv) standardized
estat gof, stat(all)
estat eqgof

sem (DEC-> dec1 dec2 dec3) (SOCVIC->socvic1 socvic2 socvic3), method(mlmv) var(DEC@1 SOCVIC@1) standardized
estat gof, stat(all)
estat eqgof

*generates economic belief measures
sem (IDIOECON-> idio_*) (EGOECON-> ego_*), var(IDIOECON@1 EGOECON@1) method(mlmv) standardized cov(e.idio_future*e.ego_future)  cov(e.idio_now*e.idio_past) cov(e.idio_folks*e.ego_now)
estat gof, stat(all)
estat eqgof

sem (ECONEVAL-> idio_now idio_past idio_future ego_now ego_past ego_future), method(mlmv) standardized cov(e.idio_future*e.ego_future) cov(e.idio_now*e.idio_past) cov(e.idio_now*e.ego_now) var(ECONEVAL@1)
estat gof, stat(all)
estat eqgof

log close
